//
//  Utils.m
//  e-nurse
//
//  Created by  on 12/12/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "Utils.h"

@protocol Utils



@end

@implementation Utils



+(BOOL)checkExpression:(NSString *)expStr string:(NSString*)str
{
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:expStr 
                                                                           options:NSRegularExpressionCaseInsensitive 
                                                                             error:nil];
    return [regex numberOfMatchesInString:str options:0 range:NSMakeRange(0, [str length])] != 0;
}

+ (BOOL)checkFloat:(NSString *)floatStr
{
    return [Utils checkExpression:@"^(?:|0|[1-9]\\d*)(?:\\.\\d*)?$" string:floatStr];
}

+ (BOOL)checkInt:(NSString *)intStr
{
    return [Utils checkExpression:@"^[+]?[0-9]+$" string:intStr];
}

+ (NSString *)formatValue:(int)value forDigits:(int)zeros {
    NSString *format = [NSString stringWithFormat:@"%%0%dd", zeros]; 
    return [NSString stringWithFormat:format,value];
}


@end
